import request from '@/utils/request';
import moment from 'moment'

// 查询列表
export async function lostPageList(data, hiddenData) {
  if (!data.flightDate && !hiddenData.flightDate) {
    delete data.flightDate
  } else {
    data.flightDate = data.flightDate ? moment(data.flightDate).format('YYYY-MM-DD') : moment(hiddenData.flightDate).format('YYYY-MM-DD')
  }
  if (!data.putStorageStart) {
    delete data.putStorageStart
  } else {
    data.putStorageStart = moment(data.putStorageStart).format('YYYY-MM-DD 00:00:00')
  }
  if (!data.putStorageEnd) {
    delete data.putStorageEnd
  } else {
    data.putStorageEnd = moment(data.putStorageEnd).format('YYYY-MM-DD 23:59:59')
  }

  return request('/luggage/lost/articles/lostPageList', {
    method: 'post',
    data
  });
}

// 获取所有入库人
export function getAllPutStoragePeople() {
  return request('/luggage/lost/articles/getAllPutStoragePeople', {
    method: 'get'
  });
}

// 删除遗失物品
export function deleteLostArticles(params) {
  return request('/luggage/lost/articles/deleteLostArticles', {
    method: 'post',
    params
  });
}

// 遗失物品领取
export function lostArticlesClaim(data) {
  data.deliveryTime = moment(data.deliveryTime).format('YYYY-MM-DD 00:00:00')
  return request('/luggage/lost/articles/lostArticlesClaim', {
    method: 'post',
    data
  });
}

// 违禁品移交
export function handoverOfContraband(params) {
  return request('/luggage/lost/articles/handoverOfContraband', {
    method: 'get',
    params
  });
}

// 遗失物品列表导出
export async function exportChart(data, hiddenData) {
  if (!data.flightDate && !hiddenData.flightDate) {
    delete data.flightDate
  } else {
    data.flightDate = data.flightDate ? moment(data.flightDate).format('YYYY-MM-DD') : moment(hiddenData.flightDate).format('YYYY-MM-DD')
  }
  if (!data.putStorageStart) {
    delete data.putStorageStart
  } else {
    data.putStorageStart = moment(data.putStorageStart).format('YYYY-MM-DD 00:00:00')
  }
  if (!data.putStorageEnd) {
    delete data.putStorageEnd
  } else {
    data.putStorageEnd = moment(data.putStorageEnd).format('YYYY-MM-DD 23:59:59')
  }

  return request('/luggage/lost/articles/lostList/export', {
    method: 'post',
    data,
    responseType: "blob"
  });
}

// 易腐物品分页列表
export function lostPerishablePage(params) {
  return request('/luggage/lost/articles/lostPerishablePage', {
    method: 'get',
    params
  });
}

// 报废易腐物品
export function scrapPerishables(params) {
  return request('/luggage/lost/articles/scrapPerishables', {
    method: 'get',
    params
  });
}